package edu.gatech.cuckoo;

import java.util.Map.Entry;

/**
 * Class represents an entry containing a key and value
 * 
 * Don't modify this class
 */
public class MapEntry<K,V> implements Entry<K, V> {
	
	private K key;
	private V value;
	
	public MapEntry(K key,V value){
		this.key = key;
		this.value = value;
	}

	@Override
	public K getKey() {
		return key;
	}

	@Override
	public V getValue() {
		return value;
	}

	@Override
	public V setValue(V value) {
		V temp = this.value;
		this.value = value;
		return temp;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MapEntry other = (MapEntry) obj;
		if (key == null) {
			if (other.key != null)
				return false;
		} else if (!key.equals(other.key))
			return false;
		if (value == null) {
			if (other.value != null)
				return false;
		} else if (!value.equals(other.value))
			return false;
		return true;
	}
	
	public String toString(){
		return "Key: " + key + " " + "Value: " + value;
	}

}
